package com.david.zhufengfm.tasks;

import android.os.AsyncTask;
import android.util.Log;

import com.david.zhufengfm.Constants;
import com.david.zhufengfm.client.ClientAPI;
import com.david.zhufengfm.utils.EntityParseUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by David on 2015/10/20.
 * qq:978944820
 */
public class DiscoverRecommendTask extends BaseTask {

    public DiscoverRecommendTask(TaskCallback callback) {
        super(callback);
    }

    @Override
    protected TaskResult doInBackground(String... params) {
        Log.i("recommend","isthere");
        TaskResult ret=new TaskResult();
        ret.action= Constants.TASK_ACTION_DISCOVER_RECOMMEND;
        JSONObject jsonObject = ClientAPI.getDisCoverRecommend("and-f6", true, true);

        if (jsonObject != null) {
            try {
                ret.resultCode=jsonObject.getInt("ret");
                //解析数据
                ret.data= EntityParseUtil.parseDiscoverRecommend(jsonObject);

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return ret;
    }

    @Override
    protected void onPostExecute(TaskResult result) {
        super.onPostExecute(result);
    }
}
